<template>
<div class="col-side">
  <div class="menu-box">
  	<Collapse v-for="(item,index) in itemJson" class="menu" style="background: #fff;">
        <Panel class="menu-title" name="index">
            {{item.header}}
            <p slot="content" class="menu-item" v-for="child in item.childrens">
            	<router-link :to="{ name: child.path }">{{child.name}}</router-link>
            </p>
        </Panel>
    </Collapse>
		 <!--<dl v-for="item in itemJson" class="menu">
			<dt class="menu-title"><i class="icon-menu" style="background:url(http://7xl6qe.com2.z0.glb.qiniucdn.com/img/icon_menu_statistics.png) no-repeat;"></i>{{item.header}}</dt>
				<dd class="menu-item" v-for="child in item.childrens">
					<router-link :to="{ name: child.path }" @click.native="flushCom(child.path)">{{child.name}}</router-link>
				</dd>
		</dl>-->
  </div>
</div>
</template>

<script>
	export default{
		data(){
			return{
				type:0,
				level:1,
				itemJson :[],
				historyPath:''
			}
		},
		methods:{
			getJurisdiction(){
			var _this = this;
      $.post('/helsinki/admin/isLogin', {}, function(res) {
				if (res.errcode == 0) {
					var type = res.data.type;
					_this.level = res.data.level;
					if(type == 5 && _this.level == 3){
						_this.itemJson = require('../menu/menuJson_'+type+'_'+_this.level+'.json');
					}else{
						_this.itemJson = require('../menu/menuJson_'+type+'.json');
					}
				
					
				}else{
					_this.$Message.info(res.info);
				}
			});
		 }/*,
		 flushCom:function(path){
　　　　　　//router是路由实例,例如:var router = new Router({})
　　　　　　//router.go(n)是路由的一个方法，意思是在history记录中前进或者后退多少步，0就表示还是当前，类似window.history.go(n)
				var paths = '/' + path;
				if(paths == this.historyPath){
					this.$router.go(0);
				}else{
					this.historyPath = this.$router.history.current.path;
					console.log(this.historyPath);
				}
　　　　}*/
		},
		mounted:function(){
			this.getJurisdiction();
		}
	}

</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style>
 @import "../static/style.css";
</style>
